﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Globalization;
using System.Threading;

namespace IDE_week2_Forms_project
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            // Sets the UI culture to German (Germany).
            //Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            InitializeComponent();
        }

        private void btn_OpenNewForm_Click(object sender, EventArgs e)
        {
            Form2 myform = new Form2();
            myform.Show();
        }

        private void btn_ChangeIcon_Click(object sender, EventArgs e)
        {
            this.Icon = Properties.Resources.Elton_Icon1;
        }

        //the language change method
        private void ChangeLanguage(string lang)
        {
            foreach (Control c in this.Controls)
            {
                ComponentResourceManager resources =
                      new ComponentResourceManager(typeof(Form1));
                resources.ApplyResources(c, c.Name, new CultureInfo(lang));
            }
        }//language change method

        private void btn_Change_Click(object sender, EventArgs e)
        {
            string currentLanguage = Convert.ToString(CultureInfo.CurrentCulture.Name); //get the current culture
            //MessageBox.Show("culture is: " + currentLanguage);

            if (currentLanguage != "en-US")
            {
                this.ChangeLanguage("en-US");
                currentLanguage = "en-US";
                MessageBox.Show("culture is: " + currentLanguage);
            }
            else { this.ChangeLanguage("de-DE"); currentLanguage = "de-DE"; }

        }

        private void btn_CallClass1_Click(object sender, EventArgs e)
        {
            int[] numbers = new int[10]; //an array of integers.
            Class1.MakeRandomNumber(numbers);
            label1.Text = numbers[0] + ", " + numbers[1] + ", " + numbers[2];

        }

    }//class form
}//namespace
